<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script src="${pageContext.request.contextPath}/js/getmd5.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-1.7.2.min.js" type="text/javascript"></script>
	<script type="text/javascript">
		function asubmit() {
			var add = document.getElementById("addForm");
			add.action="${pageContext.request.contextPath}/login/add.action";
			var username = document.getElementById("username");
			var password = document.getElementById("password");
			if(username.value !=0){
				if(password.value != 0){
					password.value = hex_md5(password.value);
					add.submit();
				}else{
					alert("密码不能为空，注册失败！");
					password.focus();
				}
			}else{
				alert("用户名不能为空，注册失败！");
				username.focus();
			}
			
		}
		function validate(){		
			<c:if test="${not empty msg }">alert("${msg}");</c:if>
		}
	</script>
  </head>
  
  <body onload="validate()">
	<form action="#" method="post" id="addForm">
    		用户名：<input type="text" name="user.username" id="username" />
    		<span id="span_name" >*</span><br />
    		密码：<input type="password" name="user.pwd"  id="password"/>
    		<span id="span_pwd">*</span>
    		<s:token/>
    		<input type="button" value="注册" onclick="asubmit()">
    	</form>
    	<span>注带*不能为空</span>
  </body>
</html>
